home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWCollectable.z / RWCollectable
Encoding:
Text File  |  1998-10-30  |  14.8 KB  |  331 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))                                        RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWCollectable - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               typedef RWCollectable Object;  // Smalltalk typedef
  13.  
  14.  
  15.  
  16.               #include <rw/collect.h>
  17.  
  18.  
  19.  
  20.  
  21. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  22.      Class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee is an abstract base class for collectable objects.
  23.      This class contains virtual functions for identifying, hashing,
  24.      comparing, storing and retrieving collectable objects.  While these
  25.      virtual functions have simple default definitions, objects that inherit
  26.      this base class will typically redefine one or more of them.
  27.  
  28. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  29.      Polymorphic
  30.  
  31. VVVViiiirrrrttttuuuuaaaallll FFFFuuuunnnnccccttttiiiioooonnnnssss
  32.               virtual
  33.           ~~~~RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee();
  34.  
  35.  
  36.      All functions that inherit class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee have virtual destructors.
  37.      This allows them to be deleted by such member functions as
  38.      rrrreeeemmmmoooovvvveeeeAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(((()))) without knowing their type.
  39.  
  40.               virtual RWspace
  41.           bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const;
  42.  
  43.  
  44.      Returns the number of bytes used by the virtual function
  45.      ssssaaaavvvveeeeGGGGuuuuttttssss((((RRRRWWWWFFFFiiiilllleeee&&&&)))) to store an object.  Typically, this involves adding up
  46.      the space required to store all primitives, plus the results of calling
  47.      rrrreeeeccccuuuurrrrssssiiiivvvveeeeSSSSttttoooorrrreeeeSSSSiiiizzzzeeee(((()))) for all objects inheriting from RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee.  See
  48.      the TTTToooooooollll....hhhh++++++++ UUUUsssseeeerrrr''''ssss GGGGuuuuiiiiddddeeee Section entitled "Virtual Function
  49.      binaryStoreSize" for details.
  50.  
  51.               virtual int
  52.           ccccoooommmmppppaaaarrrreeeeTTTToooo(const RWCollectable*) const;
  53.  
  54.  
  55.      The function  ccccoooommmmppppaaaarrrreeeeTTTToooo(((()))) is necessary to sort the items in a collection.
  56.      If pppp1111 and pppp2222 are pointers to RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee objects, the statement pppp1111----
  57.      >>>>ccccoooommmmppppaaaarrrreeeeTTTToooo((((pppp2222))));;;; should return:
  58.             0     if ****pppp1111 "is equal to" ****pppp2222;
  59.           >0     if ****pppp1111 is "larger" than ****pppp2222;
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))                                        RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.           <0     if ****pppp1111 is "smaller" than ****pppp2222.  Note that the meaning of "is
  75.      equal to," "larger" and "smaller" is left to the user.  The default
  76.      definition provided by the base class is based on the addresses, i.e.,
  77.      rrrreeeettttuuuurrrrnnnn tttthhhhiiiissss ======== pppp2222 ???? 0000 :::: ((((tttthhhhiiiissss >>>> pppp2222 ???? 1111 :::: ----1111))));;;; and is probably not very
  78.      useful.
  79.  
  80.               virtual unsigned
  81.           hhhhaaaasssshhhh() const;
  82.  
  83.  
  84.      Returns a hash value.  This function is necessary for collection classes
  85.      that use hash table look-up.  The default definition provided by the base
  86.      class hashes the object's address:  rrrreeeettttuuuurrrrnnnn ((((uuuunnnnssssiiiiggggnnnneeeedddd))))tttthhhhiiiissss;;;; It is
  87.      important that the hash value be the same for all objects which return
  88.      TTTTRRRRUUUUEEEE to iiiissssEEEEqqqquuuuaaaallll(((()))).
  89.  
  90.               virtual RWClassID
  91.           iiiissssAAAA() const;
  92.  
  93.  
  94.      Returns a class identification number (typedef'd to be an uuuunnnnssssiiiiggggnnnneeeedddd
  95.      sssshhhhoooorrrrtttt).  The default definition returns ________RRRRWWWWCCCCOOOOLLLLLLLLEEEECCCCTTTTAAAABBBBLLLLEEEE.  Identification
  96.      numbers greater than or equal to 0x8000 (hex) are reserved for Rogue Wave
  97.      objects.  User defined classes should define iiiissssAAAA() to return a number
  98.      between 0 and 0x7FFF.
  99.  
  100.               virtual RWBoolean
  101.           iiiissssEEEEqqqquuuuaaaallll(const RWCollectable* t) const;
  102.  
  103.  
  104.      Returns TTTTRRRRUUUUEEEE if collectable object "matches" object at address tttt.  The
  105.      default definition is: rrrreeeettttuuuurrrrnnnn tttthhhhiiiissss ======== tttt;;;; iiii....eeee...., both objects have the same
  106.      address (a test for iiiiddddeeeennnnttttiiiittttyyyy).  The definition may be redefined in any
  107.      consistent way.
  108.  
  109.               virtual RWCollectable*
  110.           nnnneeeewwwwSSSSppppeeeecccciiiieeeessss() const;
  111.  
  112.  
  113.      Allocates a new object off the heap of the same type as self and returns
  114.      a pointer to it.  You are responsible for deleting the object when done
  115.      with it.
  116.  
  117.               virtual void
  118.           rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWFile&);
  119.  
  120.  
  121.      Read an object's state from a binary file, using class RRRRWWWWFFFFiiiilllleeee, replacing
  122.      the previous state.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))                                        RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               virtual void
  141.           rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWvistream&);
  142.  
  143.  
  144.      Read an object's state from an input stream, replacing the previous
  145.      state.
  146.  
  147.               virtual void
  148.           ssssaaaavvvveeeeGGGGuuuuttttssss(RWFile&) const;
  149.  
  150.  
  151.      Write an object's state to a binary file, using class RRRRWWWWFFFFiiiilllleeee.
  152.  
  153.               virtual void
  154.           ssssaaaavvvveeeeGGGGuuuuttttssss(RWvostream&) const;
  155.  
  156.  
  157.      Write an object's state to an output stream.
  158.  
  159.               RWStringID
  160.           ssssttttrrrriiiinnnnggggIIIIDDDD();
  161.  
  162.  
  163.      Returns the identification string for the class.  Acts virtual, although
  164.      it is not.
  165.  
  166.               RWspace
  167.           rrrreeeeccccuuuurrrrssssiiiivvvveeeeSSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const;
  168.  
  169.  
  170.      Returns the number of bytes required to store the object using the global
  171.      operator
  172.  
  173.               RWFile& operator<<(RWFile&, const RWCollectable&);
  174.  
  175.  
  176.  
  177.  
  178.  
  179.      Recursively calls bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee(((()))), taking duplicate objects into
  180.      account.
  181.  
  182. SSSSttttaaaattttiiiicccc PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  183.               static RWClassID
  184.           ccccllllaaaassssssssIIIIDDDD(const RWStringID& name);
  185.  
  186.  
  187.      Returns the result of looking up the RRRRWWWWCCCCllllaaaassssssssIIIIDDDD associated with nnnnaaaammmmeeee in
  188.      the global RWFactory.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))                                        RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.               static RWClassID
  207.           ccccllllaaaassssssssIIIIssssAAAA();
  208.  
  209.  
  210.      Returns the RRRRWWWWCCCCllllaaaassssssssIIIIDDDD of this class.
  211.  
  212.               static RWBoolean
  213.           iiiissssAAAAttttoooommmm(RWClassID id);
  214.  
  215.  
  216.      Returns TTTTRRRRUUUUEEEE if iiiidddd is the RRRRWWWWCCCCllllaaaassssssssIIIIDDDD that is associated with an
  217.      RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee class that has a programmer-chosen RRRRWWWWSSSSttttrrrriiiinnnnggggIIIIDDDD.
  218.  
  219.               static RWspace
  220.           nnnniiiillllSSSSttttoooorrrreeeeSSSSiiiizzzzeeee();
  221.  
  222.  
  223.      Returns the number of bytes required to store a rrrrwwwwnnnniiiillll pointer in an
  224.      RRRRWWWWFFFFiiiilllleeee.
  225.  
  226. RRRReeeellllaaaatttteeeedddd  GGGGlllloooobbbbaaaallll OOOOppppeeeerrrraaaattttoooorrrrssss
  227.               RWvostream&
  228.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWvostream&, const RWCollectable& obj);
  229.           RWFile&
  230.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWFile&,     const RWCollectable& obj);
  231.  
  232.  
  233.      Saves the object oooobbbbjjjj to a virtual stream or RRRRWWWWFFFFiiiilllleeee, respectively.
  234.      Recursively calls the virtual function ssssaaaavvvveeeeGGGGuuuuttttssss(((()))), taking duplicate
  235.      objects into account.  See the TTTToooooooollllssss....hhhh++++++++ UUUUsssseeeerrrr''''ssss GGGGuuuuiiiiddddeeee section entitled
  236.      "Persistence" for more information.
  237.  
  238.               RWvistream&
  239.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream&, RWCollectable& obj);
  240.           RWFile&
  241.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile&,     RWCollectable& obj);
  242.  
  243.  
  244.      Restores an object inheriting from RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee into oooobbbbjjjj from a virtual
  245.      stream or RRRRWWWWFFFFiiiilllleeee, respectively, replacing the previous contents of oooobbbbjjjj.
  246.      Recursively calls the virtual function rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(((()))), taking duplicate
  247.      objects into account. See the TTTToooooooollllssss....hhhh++++++++ UUUUsssseeeerrrr''''ssss GGGGuuuuiiiiddddeeee section entitled
  248.      "Persistence" for more information.  Various exceptions that could be
  249.      thrown are RRRRWWWWIIIInnnntttteeeerrrrnnnnaaaallllEEEErrrrrrrr (if the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy does not know how to make the
  250.      object), and RRRRWWWWEEEExxxxtttteeeerrrrnnnnaaaallllEEEErrrrrrrr (corrupted stream or file).
  251.  
  252.               RWvistream&
  253.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream&, RWCollectable*& obj);
  254.           RWFile&
  255.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile&,     RWCollectable*& obj);
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))                                        RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      Looks at the next object on the input stream or RRRRWWWWFFFFiiiilllleeee, respectively, and
  273.      either creates a new object of the proper type off the heap and returns a
  274.      pointer to it, or else returns a pointer to a previously read instance.
  275.      Recursively calls the virtual function rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(((()))), taking duplicate
  276.      objects into account.  If an object is created off the heap, then you are
  277.      responsible for deleting it. See the TTTToooooooollllssss....hhhh++++++++ UUUUsssseeeerrrr''''ssss GGGGuuuuiiiiddddeeee section
  278.      entitled "Persistence" for more information.  Various exceptions that
  279.      could be thrown are RRRRWWWWIIIInnnntttteeeerrrrnnnnaaaallllEEEErrrrrrrr (if the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy does not know how to
  280.      make the object), and RRRRWWWWEEEExxxxtttteeeerrrrnnnnaaaallllEEEErrrrrrrr (corrupted stream or file).  In case
  281.      an exception is thrown during this call, the pointer to the partly
  282.      restored object will probably be lost, and memory will leak.  For this
  283.      reason, you may prefer to use the static methods ttttrrrryyyyRRRReeeeccccuuuurrrrssssiiiivvvveeeeRRRReeeessssttttoooorrrreeee(((())))
  284.      documented above.
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.